<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /**
         * new Promise(执行器函数)
         * 
         */

        // 一下输出 1 2 3 说明执行器函数是同步的回调函数
        console.log(1);
        let p = new Promise((resolve, reject)=>{
            console.log(2);
            // resolve('ok');
            reject('error');
        })
        console.log(3);



        // p.then(成功的回调,失败的回调);  then指定的成功或失败的回调都是异步的回调函数
        p.then(value=>{
            console.log('成功', value);
        }, reason=>{
            console.log('失败', reason);
        })

        console.log('last dance');
    </script>
</body>
</html>